package com.xbongbong.paas.model.impl;

import com.xbongbong.paas.model.SearchCustomerUserModel;
import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.pro.domain.dao.SearchCustomerUserDao;
import com.xbongbong.pro.domain.entity.SearchCustomerUserEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author shian
 * @create 2019-08-07 11:31
 * @Description
 */
@Service("searchCustomerUserModel")
public class SearchCustomerUserModelImpl implements SearchCustomerUserModel {

    @Resource
    private SearchCustomerUserDao searchCustomerUserDao;

    @Override
    public Integer insert(SearchCustomerUserEntity entity) {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return searchCustomerUserDao.insert(entity);
    }

    @Override
    public Integer update(SearchCustomerUserEntity entity) {
        return searchCustomerUserDao.update(entity);
    }

    @Override
    public List<SearchCustomerUserEntity> findEntitys(Map<String, Object> param) {
        return searchCustomerUserDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return searchCustomerUserDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public void batchInsert(List<SearchCustomerUserEntity> searchCustomerUserEntityList) {
        searchCustomerUserDao.batchInsert(searchCustomerUserEntityList);
    }

    @Override
    public void updateAdmin(SearchCustomerUserEntity entity) {
        searchCustomerUserDao.updateAdmin(entity);
    }

    @Override
    public void updateStaff(SearchCustomerUserEntity entity) {
        searchCustomerUserDao.updateStaff(entity);
    }

    @Override
    public SearchCustomerUserEntity getByKey(String userId, String corpid) {
        return searchCustomerUserDao.getByKey(userId, corpid);
    }

    @Override
    public int getRegisterCount(Map<String, Object> param) {
        return searchCustomerUserDao.getRegisterCount(param);
    }

    @Override
    public List<SearchCustomerUserEntity> getUnBindInfo(Map<String, Object> param) {
        return searchCustomerUserDao.getUnBindInfo(param);
    }

    @Override
    public void save(SearchCustomerUserEntity searchCustomerUserEntity) {
        if (searchCustomerUserEntity.getId() == null || searchCustomerUserEntity.getId() == 0) {
            insert(searchCustomerUserEntity);
        } else {
            update(searchCustomerUserEntity);
        }
    }

}
